package Examples;

import guiTesting.RetrieveUserInfo;

import java.awt.Dimension;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Vector;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import com.atlassian.crowd.exception.ApplicationPermissionException;
import com.atlassian.crowd.exception.InvalidAuthenticationException;
import com.atlassian.crowd.exception.OperationFailedException;
import com.atlassian.crowd.model.user.User;

public class ListData {
	static ArrayList<User> lt;
	static RetrieveUserInfo userInfo; 
	static JTable table; 
	static Vector columnNamesV ;
	static String[] columnNames  = { "First Name ", "Last Name","Email" , "Display Name", "Is Active"};
	
	
	
	public static void main(String[] argv) throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException {
		Vector rowData = new Vector();
		userInfo = new RetrieveUserInfo();
		lt = (ArrayList<User>) userInfo.searchUsers("Br");
		for (int i = 0; i < lt.size(); i++) {
			User uz =  lt.get(i);
			Vector colData = new Vector(Arrays.asList( uz.getFirstName(), uz.getLastName(),uz.getEmailAddress(), uz.getDisplayName(),uz.isActive()));
			rowData.add(colData);

			 columnNamesV = new Vector(Arrays.asList(columnNames));
		}
			 table = new JTable(rowData, columnNamesV);
			 Dimension tbD = new Dimension(500, 400);
			 table.setMinimumSize(tbD);
			JFrame f = new JFrame();
			f.setSize(600, 600);
			f.add(new JScrollPane(table));
			f.setVisible(true);
		}
	
}